package Java实训.第四天异常;

public class Num2 {
    public static void main(String[] args) {
     System.out.println("字符串索引越界");
        int aa = 0;
        try {
            String str = args[0]; //数组越界异常
            System.out.println("第四个字符为" + str.charAt(3));//字符串下标越界异常
            aa = Integer.parseInt(args[0]);//数组越界异常或字符串转化为数字异常
        } catch (ArrayIndexOutOfBoundsException | StringIndexOutOfBoundsException | NumberFormatException e) {
            System.out.println("已捕获异常");
        }

        System.out.println("平方为" + aa*aa);
    }
}
